<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE html>
<html>
<head>
<!--
		Charisma v1.0.0

		Copyright 2012 Muhammad Usman
		Licensed under the Apache License v2.0
		http://www.apache.org/licenses/LICENSE-2.0

		http://usman.it
		http://twitter.com/halalit_usman
	-->
<meta charset="utf-8">
<title>友宝后台管理系统</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description"
	content="Charisma, a fully featured, responsive, HTML5, Bootstrap admin template.">
<meta name="author" content="Muhammad Usman">

<!-- The styles -->
<link id="bs-css" href="css/bootstrap-cerulean.css" rel="stylesheet">
<style type="text/css">
body {
	padding-bottom: 40px;
}

.sidebar-nav {
	padding: 9px 0;
}
.checkpassword{
 padding:5px;
 line-height:30px;
}
.checkpassword1{
  width:30px;
  height:28px;
  border:0px;
  margin-top:-5px;
  background:url("img/opa-icons-color32.png") -413px -30px;
}
.checkpassword2{
  width:30px;
  height:28px;
  border:0px;
  margin-top:-5px;
  background:url("img/opa-icons-color32.png") -383px -30px;
}
.checkbutton{
  width:30px;
  height:28px;
  border:0px;
  background:white;
}
</style>
<link href="css/bootstrap-responsive.css" rel="stylesheet">
<link href="css/charisma-app.css" rel="stylesheet">
<link href="css/jquery-ui-1.8.21.custom.css" rel="stylesheet">
<link href='css/fullcalendar.css' rel='stylesheet'>
<link href='css/fullcalendar.print.css' rel='stylesheet' media='print'>
<link href='css/chosen.css' rel='stylesheet'>
<link href='css/uniform.default.css' rel='stylesheet'>
<link href='css/colorbox.css' rel='stylesheet'>
<link href='css/jquery.cleditor.css' rel='stylesheet'>
<link href='css/jquery.noty.css' rel='stylesheet'>
<link href='css/noty_theme_default.css' rel='stylesheet'>
<link href='css/elfinder.min.css' rel='stylesheet'>
<link href='css/elfinder.theme.css' rel='stylesheet'>
<link href='css/jquery.iphone.toggle.css' rel='stylesheet'>
<link href='css/opa-icons.css' rel='stylesheet'>
<link href='css/uploadify.css' rel='stylesheet'>

<!-- The HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]>
	  <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
	<![endif]-->

<!-- The fav icon -->
<link rel="shortcut icon" href="img/favicon.ico">

</head>

<body>
	<jsp:include page="../header.jsp"></jsp:include>
	<!-- topbar ends -->
	<div class="container-fluid">
		<div class="row-fluid">
			<jsp:include page="../left.jsp"></jsp:include>

			<noscript>
				<div class="alert alert-block span10">
					<h4 class="alert-heading">Warning!</h4>
					<p>
						You need to have <a href="http://en.wikipedia.org/wiki/JavaScript"
							target="_blank">JavaScript</a> enabled to use this site.
					</p>
				</div>
			</noscript>

			<div id="content" class="span10">
				<!-- content starts -->


				<div>
					<ul class="breadcrumb">
						<li><a href="index">主页</a> <span class="divider">/</span></li>
						<li><a href="#">终端密码修改</a><span class="divider">/</span></li>
						<li><a href="#">${terminal.branch.branchName}&nbsp;${terminal.name}</a></li>
					</ul>
				</div>
				
               <!-- 修改密码提示 -->
               <div class="alert alert-warning alert-dismissable" style="display:none;">
                        <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
                        <span></span>
               </div>

               <input type="hidden" value="${terminal.terminalId}" id="terminalId"/>
				<div class="sortable row-fluid">
					<div class="box-content">
						<form class="form-horizontal" action="registerTerminal" method="post" id="form">
						  <fieldset>
						   <div class="control-group">
								<label class="control-label" for="branch">请输入原密码：</label>
								<div class="controls">
                                     <input name="terminal.name" password="${terminal.terminalId}" type="password" class="span4 typeahead oldPassword" id="name" data-items="2" style="float: left;"/>&nbsp;<button disabled="disabled" class="checkbutton" id="checkpasswordButton"></button><span class="checkpassword"></span>
								</div>
							  </div>
							<div class="control-group">
							  <label class="control-label" for="typeahead">请输入新密码:</label>
							  <div class="controls">
								<input name="terminal.name" type="password" class="span4 typeahead newPassword1" id="name" data-items="2" style="float: left;"/>
							  </div>
							</div>
							<div class="control-group">
							  <label class="control-label" for="password">确认新密码:</label>
							  <div class="controls">
								<input name="terminal.cardNumber" type="password" class="span4 typeahead newPassword2" id="card" data-items="2" style="float: left;"/>&nbsp;<button disabled="disabled"  class="checkbutton" id="checknewpasswordButton"></button><span class="checknewpassword"></span>
							  </div>
							</div>
							  <div class="form-actions">
								<button type="button" class="btn btn-primary" id="submitPassword">修改</button>
								&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
								<button class="btn" type="button" onclick="window.history.go(-1);">返回</button>
							  </div>																					
						  </fieldset>
						</form> 
					</div>
				</div>
				<!-- content ends -->
			</div>
			<!--/#content.span10-->
		</div>
		<!--/fluid-row-->

		<hr>
		<jsp:include page="../footer.jsp"></jsp:include>

	</div>



	<!--/.fluid-container-->

	<!-- external javascript
	================================================== -->
	<!-- Placed at the end of the document so the pages load faster -->

	<!-- jQuery -->
	<script src="js/jquery-1.7.2.min.js"></script>
	<!-- jQuery UI -->
	<script src="js/jquery-ui-1.8.21.custom.min.js"></script>
	<!-- transition / effect library -->
	<script src="js/bootstrap-transition.js"></script>
	<!-- alert enhancer library -->
	<script src="js/bootstrap-alert.js"></script>
	<!-- modal / dialog library -->
	<script src="js/bootstrap-modal.js"></script>
	<!-- custom dropdown library -->
	<script src="js/bootstrap-dropdown.js"></script>
	<!-- scrolspy library -->
	<script src="js/bootstrap-scrollspy.js"></script>
	<!-- library for creating tabs -->
	<script src="js/bootstrap-tab.js"></script>
	<!-- library for advanced tooltip -->
	<script src="js/bootstrap-tooltip.js"></script>
	<!-- popover effect library -->
	<script src="js/bootstrap-popover.js"></script>
	<!-- button enhancer library -->
	<script src="js/bootstrap-button.js"></script>
	<!-- accordion library (optional, not used in demo) -->
	<script src="js/bootstrap-collapse.js"></script>
	<!-- carousel slideshow library (optional, not used in demo) -->
	<script src="js/bootstrap-carousel.js"></script>
	<!-- autocomplete library -->
	<script src="js/bootstrap-typeahead.js"></script>
	<!-- tour library -->
	<script src="js/bootstrap-tour.js"></script>
	<!-- library for cookie management -->
	<script src="js/jquery.cookie.js"></script>
	<!-- calander plugin -->
	<script src='js/fullcalendar.min.js'></script>
	<!-- data table plugin -->
	<script src='js/jquery.dataTables.min.js'></script>

	<!-- chart libraries start -->
	<script src="js/excanvas.js"></script>
	<script src="js/jquery.flot.min.js"></script>
	<script src="js/jquery.flot.pie.min.js"></script>
	<script src="js/jquery.flot.stack.js"></script>
	<script src="js/jquery.flot.resize.min.js"></script>
	<!-- chart libraries end -->

	<!-- select or dropdown enhancer -->
	<script src="js/jquery.chosen.min.js"></script>
	<!-- checkbox, radio, and file input styler -->
	<script src="js/jquery.uniform.min.js"></script>
	<!-- plugin for gallery image view -->
	<script src="js/jquery.colorbox.min.js"></script>
	<!-- rich text editor library -->
	<script src="js/jquery.cleditor.min.js"></script>
	<!-- notification plugin -->
	<script src="js/jquery.noty.js"></script>
	<!-- file manager library -->
	<script src="js/jquery.elfinder.min.js"></script>
	<!-- star rating plugin -->
	<script src="js/jquery.raty.min.js"></script>
	<!-- for iOS style toggle switch -->
	<script src="js/jquery.iphone.toggle.js"></script>
	<!-- autogrowing textarea plugin -->
	<script src="js/jquery.autogrow-textarea.js"></script>
	<!-- multiple file upload plugin -->
	<script src="js/jquery.uploadify-3.1.min.js"></script>
	<!-- history.js for cross-browser state change on ajax -->
	<script src="js/jquery.history.js"></script>
	<!-- application script for Charisma demo -->
	<script src="js/charisma.js"></script>
    <script type="text/javascript">
    $(function(){
    	$(".oldPassword").blur(function(){
    		$.post("Terminals!checkPassword?terminalID="+$(this).attr("password")+"&oldpassword="+$(this).val(), function(v){
    			if(v=="1"){
    				$(".checkpassword").html("请输入正确的原密码！").css("color","red");
    				$("#checkpasswordButton").removeClass("checkpassword1");
    				$("#checkpasswordButton").removeClass("checkbutton");
    				$("#checkpasswordButton").addClass("checkpassword2");
    			}else{
    				$(".checkpassword").html("输入正确！").css("color","green");
    				$("#checkpasswordButton").removeClass("checkbutton");
    				$("#checkpasswordButton").removeClass("checkpassword2");
    				$("#checkpasswordButton").addClass("checkpassword1");
    			}
    		});
    		checkOldNewpassword();
    	});
    	$(".oldPassword").focus(function(){
    		$(".checkpassword").html("");
    		$("#checkpasswordButton").removeClass("checkpassword1");
    		$("#checkpasswordButton").removeClass("checkpassword2");
    		$("#checkpasswordButton").addClass("checkbutton");
    	});
    	
    	$(".newPassword2").blur(function(){
    		checkOldNewpassword();
    	});
    	
    	var checkOldNewpassword=function(){
    		if($(".newPassword1").val()!=""&&$(".newPassword1").val()==$(".newPassword2").val()&&$(".newPassword1").val()!=$(".oldPassword").val()){
    			$(".checknewpassword").html("输入正确！").css("color","green");
				$("#checknewpasswordButton").removeClass("checkbutton");
				$("#checknewpasswordButton").removeClass("checkpassword2");
				$("#checknewpasswordButton").addClass("checkpassword1");
    		}else{
    			if($(".newPassword1").val()==$(".oldPassword").val())
    		    $(".checknewpassword").html("新密码和旧密码一致，请重新输入！").css("color","red");
    			else
    			$(".checknewpassword").html("两次密码输入不一致,或新密码为空，请重新输入！").css("color","red");
				$("#checknewpasswordButton").removeClass("checkbutton");
				$("#checknewpasswordButton").removeClass("checkpassword1");
				$("#checknewpasswordButton").addClass("checkpassword2");
    		}
    	}
    	
    	$(".newPassword2,newPassword1").focus(function(){
    		$(".checknewpassword").html("");
    		$("#checknewpasswordButton").removeClass("checkpassword1");
    		$("#checknewpasswordButton").removeClass("checkpassword2");
    		$("#checknewpasswordButton").addClass("checkbutton");
    	});
    	
    	$("#submitPassword").click(function(){
    		if($(".checknewpassword").html()=="输入正确！"&&$(".checkpassword").html()=="输入正确！"&&$(".newPassword2").val().trim()!=""){
    			$.post("Terminals!updateNewPassword?terminalID="+$("#terminalId").val()+"&newpassword="+$(".newPassword2").val().trim(),function(v){
    				var str=v.substring(0,1);
    				if(str=="0"){
    					$(".alert-warning").css("display","block").find("span").html("修改成功,请记住你的新密码："+v.substring(2));
    				}else{
    					$(".alert-warning").css("display","block").find("span").html("修改失败");
    				}
    				$(".newPassword2,.newPassword1,.oldPassword").val("");
    	    		$(".checkpassword").html("");
    	    		$("#checkpasswordButton").removeClass("checkpassword1");
    	    		$("#checkpasswordButton").removeClass("checkpassword2");
    	    		$("#checkpasswordButton").addClass("checkbutton");
    	    		$(".checknewpassword").html("");
    	    		$("#checknewpasswordButton").removeClass("checkpassword1");
    	    		$("#checknewpasswordButton").removeClass("checkpassword2");
    	    		$("#checknewpasswordButton").addClass("checkbutton");
    			});
    		}else{
    			$(".alert-warning").css("display","block").find("span").html("请正确输入旧密码和新密码！");
    		}
    	});
    });
    </script>
</body>
</html>
